import { Login, mobileCode } from '@/api/login';
import { setToken } from '@/utils/local';

export const getCode = (mobile: string) => {
  return async () => {
    await mobileCode(mobile);
  };
};
export type LoginType = {
  mobile: string;
  code: string;
};
export const getToken = (data: LoginType) => {
  return async (dispatch: any) => {
    const res = await Login(data);
    setToken(res.data);
    dispatch({
      type: 'login/token',
      payload: res.data,
    });
  };
};
